package tech.aistar.day04.ses;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

@WebServlet(urlPatterns = "/session/create")
public class SessionCreateController extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //假设请求中带有参数
        String remark = req.getParameter("remark");
        //将参数值放入到session作用域中.
        HttpSession ses = req.getSession();

        //生命周期是浏览器开启 - 浏览器关闭
        ses.setAttribute("remark",remark);

        resp.sendRedirect("/servlet/session/get");
    }
}
